<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">

           			<tr>
           				<td style="width:90px;text-align: right;padding-top: 80px;">基本信息:</td>
           				<td>
           					<p style="float: left;">

             停车场名称：<span id="parkName" >
           {{result.parkName }}
                    </span><br>

             出口名称：<span id="armName" >
           {{result.armName }}
                    </span><br>

             停车场出口编号：<span id="armCode" >
           {{result.armCode }}
                    </span><br>

             车牌号：<span id="plateNo" >
           {{result.plateNo }}
                    </span><br>

             开闸类型：<span id="swichType" >
           {{"0" == result.swichType ? '场端开闸'
           : "1"  == result.swichType ? '自动开闸'
           : "2"  == result.swichType ? '手持端开闸'
           : "3"  == result.swichType ? '云端开闸'
           : result.swichType}}
                    </span><br>

             开闸放行备注：<span id="remark" >
           {{result.remark }}
                    </span><br>

             车辆进出场地点 出口名称/出口ip/出口设备编码 ：<span id="capPlace" >
           {{result.capPlace }}
                    </span><br>

            创建时间：<span id="createTime" >
           {{result.createTime }}
                    </span><br>
	</p>
			</td>
                			</tr>

                				<tr>
                                    <td style="width:90px;text-align: right;padding-top: 100px;">详情:</td>
                                    <td>
                                        <p style="float: left;">
                                              通道：<span id="channelNum" >
                                            {{result.channelNum }}
                                                      </span><br>


                                              返回控制指令信息：<span id="cmd" >
                                            {{result.cmd }}
                                                      </span><br>


                                              继电器闭合时间(毫秒)：<span id="delay" >
                                            {{result.delay }}
                                                      </span><br>


                                              返回信息：<span id="errorMsg" >
                                            {{result.errorMsg }}
                                                      </span><br>


                                              控制指令信息：<span id="info" >
                                            {{result.info }}
                                                      </span><br>


                                              设备ip地址：<span id="ipAddr" >
                                            {{result.ipAddr }}
                                                      </span><br>


                                              消息记录id：<span id="msgId" >
                                            {{result.msgId }}
                                                      </span><br>


                                              停车场编号：<span id="parkCode" >
                                            {{result.parkCode }}
                                                      </span><br>


                                              设备序列号：<span id="serialNo" >
                                            {{result.serialNo }}
                                                      </span><br>


                                              返回code：<span id="stateCode" >
                                            {{result.stateCode }}
                                                      </span><br>

                                        </p>
                                    </td>
                            	</tr>

                			<tr>
                				<td style="text-align: center;" colspan="10">
                                 <a-button type="primary" @click="close">关闭</a-button>
                				</td>
                			</tr>
                		</table>

  </a-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'

  export default {
    name: "SdkOpenGateLogModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
         result: {

                },
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/mqtt/mqttOpenGateLog/add",
          edit: "/mqtt/mqttOpenGateLog/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
             Object.assign(this.result, record);
              this.visible = true;
            },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化

            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })



          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>